package com.fjwt.gz.service.activity.platform.acte017;

import com.fjwt.gz.db.dto.ActivityAwardDTO;
import com.fjwt.gz.db.entity.SysExportTaskEntity;
import com.fjwt.gz.db.vo.StatActe017NumVO;
import com.fjwt.gz.service.activity.AbstractExportReport;
import com.fjwt.gz.service.impl.StatActe017NumService;
import com.fjwt.gz.service.impl.StatActe017RecordService;
import com.fjwt.gz.service.mapper.StatActe017NumMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ------ 越减越便宜-商户版 活动发展通报
 * @author myf
 */
@Slf4j
@Service
public class MchProgressExportReport extends AbstractExportReport<StatActe017NumVO> {

    @Autowired
    private StatActe017NumMapper statActe017NumMapper;

    private static final Map<String, String> HEADER_ALIAS_MAP = new HashMap<>();
    static {
        HEADER_ALIAS_MAP.put("agentName3", "区县");
        HEADER_ALIAS_MAP.put("nextAgentNum", "网点数");
        HEADER_ALIAS_MAP.put("joinManNum", "活动参与人数");
        HEADER_ALIAS_MAP.put("joinManTime", "活动参与人次");
        HEADER_ALIAS_MAP.put("joinManTimeAverage", "活动参与点均");
        HEADER_ALIAS_MAP.put("joinManNumSort", "活动参与点均排名");
        HEADER_ALIAS_MAP.put("promoteManNum", "客户激发人数");
        HEADER_ALIAS_MAP.put("promoteManNumAverage", "客户激发点均");
        HEADER_ALIAS_MAP.put("promoteManNumSort", "客户激发点均排名");
        HEADER_ALIAS_MAP.put("promoteManCoverage", "客户激发覆盖率");
        HEADER_ALIAS_MAP.put("totalB1GetNum", "B1券激发人次");
        HEADER_ALIAS_MAP.put("totalB1GetNumAverage", "B1券点均");
        HEADER_ALIAS_MAP.put("totalB1GetNumSort", "B1券点均排名");
        HEADER_ALIAS_MAP.put("totalB1ActiveRate", "B1券激活率");
        HEADER_ALIAS_MAP.put("totalB2GetNum", "B2福分激发人次");
        HEADER_ALIAS_MAP.put("totalB2GetNumAverage", "B2福分点均");
        HEADER_ALIAS_MAP.put("totalB2GetNumSort", "B2福分点均排名");
        HEADER_ALIAS_MAP.put("totalB3GetNum", "B3券激发人次");
        HEADER_ALIAS_MAP.put("totalB3GetNumAverage", "B3券点均");
        HEADER_ALIAS_MAP.put("totalB3ActiveNumSort", "B3券点均排名");
        HEADER_ALIAS_MAP.put("totalB3ActiveRate", "B3券激活率");
        HEADER_ALIAS_MAP.put("totalCGetNum", "C券激发人次");
        HEADER_ALIAS_MAP.put("totalCGetNumAverage", "C券点均");
        HEADER_ALIAS_MAP.put("totalCActiveNumSort", "C券点均排名");
        HEADER_ALIAS_MAP.put("totalCActiveRate", "C券激活率");
        HEADER_ALIAS_MAP.put("totalDGetNum", "D实物激发人次");
        HEADER_ALIAS_MAP.put("totalDGetNumAverage", "D实物点均");
        HEADER_ALIAS_MAP.put("totalDActiveNumSort", "D实物点均排名");
        HEADER_ALIAS_MAP.put("totalDActiveRate", "D实物实物激活率");
        HEADER_ALIAS_MAP.put("totalGrade", "综合得分");
        HEADER_ALIAS_MAP.put("totalGradeSort", "综合排名");
    }


    @Override
    public String exportActivityExcel(SysExportTaskEntity sysExportTaskEntity) {
        ActivityAwardDTO activityAwardDTO = getRequestParam(sysExportTaskEntity.getRequestParam(), ActivityAwardDTO.class);
        List<StatActe017NumVO> result = this.statActe017NumMapper.getStatMchV(activityAwardDTO);
        return createExcelAndUploadOssUrl(result, HEADER_ALIAS_MAP, sysExportTaskEntity);
    }
}
